<?php session_start(); ?>
<?php
include('../ketnoi.php');
include_once("fckeditor/fckeditor.php") ;
if (!$_SESSION['user']) header("location: index.php"); // nếu biến session['banguyen'] chưa có thì trở về trang đăng nhập, copy dòng này vào trang nào muốn bảo vệ bằng mật khẩu
?>
<style type="text/css">
<!--
.error, .notice, .success {padding:.8em;margin:auto; margin-bottom:.5em;border:2px solid #AAF;width:570px;text-align: center}
.error {background: #ECECFF;color: red;border-color:#AAF;}
-->
</style>
<script type="text/javascript" src="scripts/joomla.js"></script>
<div class="m">
 <?php 
    $shop=$dulieu;
	if($_GET['action']=='view' && $_GET['option']=='com_trungtam')
	{
		$sql1 = "SELECT * FROM `".$shop."`.`trungtam`";
		$kq = mysql_query($sql1);
		$dulieu = mysql_fetch_array($kq);
?>
<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="index.php"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>
	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" href="?option=com_trungtam&action=update&amp;id=<?php echo $dulieu['Ten'] ?>"><img src="images/toolbar/icon-32-edit.png"  alt="New"><br><span>Edit</span></a>
	</div>
	</div>
</div>

<div class="header">
  <h2 style="margin: 0px;"><img src="images/dashboard/store.png" alt="Store" align="absmiddle" border="0">&nbsp;&nbsp;&nbsp;Thông tin Trung tâm</h2></div><br /><br />
<form method="post" action="" name="adminForm" enctype="multipart/form-data" target="_self"><br><br>
  <table width="800" class="adminform" style="font-size:16px">
    <tbody><tr> 
 		<td valign="top" width="500"><br>
		  <fieldset>
		  <legend>Thông tin trung tâm</legend>
	 		<table width="500" class="adminform">
			    <tbody>
			    <tr> 
			      <td width="103" class="labelcell">Trung tâm :</td>
			      <td width="385"> 
		         <?php echo $dulieu['Tentv']?></td>
			    </tr>
               <tr> 
			      <td width="103" class="labelcell">&nbsp;</td>
			      <td width="385"> 
		         <?php echo $dulieu['Ten']?></td>
			    </tr>
			    <tr> 
			      <td class="labelcell">Website :</td>
			      <td width="385"> 
		           <?php echo $dulieu['web']?>   </td>
			    </tr>
			    <tr> 
			      <td class="labelcell">Địa chỉ :</td>
			      <td width="385"> 
		         <?php echo $dulieu['diachi']?>    </td>
			    </tr>
			    <tr> 
			      <td class="labelcell">&nbsp;</td>
			      <td width="385">&nbsp; </td>
			    </tr>
		    </tbody></table>
		    </fieldset>
 		</td>
 		
    	<td valign="top" width="300"><br>
		  			  <fieldset>
			  <legend>Thông tin liên hệ</legend>
			  <table width="300" class="adminform">
			    <tbody>
			    <tr> 
			      <td width="116" class="labelcell"> Điện thoại:</td>
			      <td width="172"> 
		         <?php echo $dulieu['sdt']?>  </td> 	 	 
			    </tr>
			    
			    <tr> 
			      <td class="labelcell"> Fax :</td>
			      <td width="172"> 
				   <?php if($dulieu['fax']=='') echo "#" ;else echo $dulieu['fax'];?>		         </td>
			    </tr>
			    <tr> 
			      <td class="labelcell"> Email :</td>
			      <td width="172"> 
		         <?php echo $dulieu['mail']?>       </td>
			    </tr>
                 
			    <tr> 
			      <td colspan="2" align="center">&nbsp;</td>
			    </tr>
			  </tbody></table>
			  </fieldset>
 		</td>
 	</tr>
	
	<tr align="justify"> 
 		<td colspan="2" valign="top" width="800" align="justify"><br>
		  <fieldset>
		  <legend>Giới thiệu trung tâm</legend>
	 		<table width="800" class="adminform">
			    <tbody>
			    <tr align="justify"> 
			      <td width="36" class="labelcell">&nbsp;</td>
			      <td width="752" align="justify" style="padding-bottom:20px; padding-top:20px"> <?php echo $dulieu['goithieu']?></td>
			    </tr>
		    </tbody></table>
		    </fieldset>
 		</td>
 	</tr>
	
	
</tbody></table>
</form>

<?php
}//ket thuc view

if($_GET['action']=='update' && $_GET['option']=='com_trungtam')
	{
if($_GET['id']!=''){
		$_SESSION['maso']= $_GET['id'];
}
		$sql ="SELECT * from `".$shop."`.`trungtam` where Ten = '".$_SESSION['maso']."'";
		$ketqua = mysql_query($sql);
		$dulieu = mysql_fetch_array($ketqua);
		
		if (  isset($_POST['ts1']) ){

if ( isset( $_POST ) )
   $postArray = &$_POST ;			// 4.1.0 or later, use $_POST
else
   $postArray = &$HTTP_POST_VARS ;	// prior to 4.1.0, use HTTP_POST_VARS	

$stt=0;
while (list($sForm,$value)=each($postArray))
{
$stt++;
if ( get_magic_quotes_gpc() )
	$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
else
	$postedValue = htmlspecialchars( $value ) ;
$b[$stt]=$postedValue;
}	
 ?>
 	<form  name="form2" method="post">
    <input name="txt1" type="hidden"  id="txt1" value="<?=$b[1]?>" />
    <input name="txt2"  type="hidden" id="txt2" value="<?=$b[2]?>" />
    <input name="txt3" type="hidden" id="txt3" value="<?=$b[3]?>"/>
    <input name="txt4" type="hidden" id="txt4" value="<?=$b[4]?>"/>
	<input name="txt5"  type="hidden" id="txt5" value="<?=$b[5]?>"/>
    <input name="txt6" type="hidden"  id="txt6" value="<?=$b[6]?>" />
    <input name="txt7"  type="hidden" id="txt7" value="<?=$b[7]?>" />
    <input name="txt8" type="hidden" id="txt8" value="<?=$b[8]?>"/>
	</form>
	
	<script language="JavaScript" type="text/javascript">
 		document.form2.submit();
    </script> 
 <?php

}



if(isset( $_POST['txt1'] )){ 
 	$error="";
	if($_POST['txt1']=="" ){
	  $error="Vui lòng nhập đầy đủ các field.";   	 	 	 	 	 	 	
    }else{
        $sql = "UPDATE `".$shop."`.`trungtam` SET  `Ten` = '".$_POST['txt1']."', `Tentv` = '".$_POST['txt2']."', `web` = '".$_POST['txt3']."', `diachi` = '".$_POST['txt4']."',  `sdt` = '".$_POST['txt5']."',`fax` = '".$_POST['txt6']."', `mail` = '".$_POST['txt7']."', `goithieu` = '".$_POST['txt8']."' WHERE `trungtam`.`Ten` = '".$_SESSION['maso']."'";
		$update = mysql_query($sql) or die($sql);
        echo"<script language=javascript>window.location='index.php?option=com_trungtam&action=view';</script>";
	}
}
	?>
<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="?option=com_trungtam&action=view"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>
	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" onClick="adminForm3.submit();"><img src="images/toolbar/icon-32-save.png"  alt="New"><br><span>Save</span></a>
	</div>
	</div>
</div>


<div class="header"><h2 style="margin: 0px;"><img src="images/dashboard/store.png" alt="Store" align="absmiddle" border="0">&nbsp;&nbsp;&nbsp;Sửa Thông tin trung tâm</h2></div><br /><br />
<form method="post" action="" name="adminForm3" enctype="multipart/form-data" target="_self"><br><br>
  <table width="800" class="adminform" style="font-size:16px">
    <tbody><tr> 
 		<td valign="top" width="500"><br>
		  <fieldset>
		  <legend>Thông tin trung tâm</legend>
	 		<table width="500" class="adminform">
			    <tbody>
			    <tr> 
			      <td width="103" class="labelcell">Trung tâm :</td>
			      <td width="385"> <input name="ts1" type="text" style="width:300px" value="<?php echo $dulieu['Ten']?>" />
		          </td>
			    </tr>
                 <tr> 
			      <td width="103" class="labelcell">&nbsp;</td>
			      <td width="385"> <input name="ts2" type="text" style="width:300px" value="<?php echo $dulieu['Tentv']?>" />
		          </td>
			    </tr>
			    <tr> 
			      <td class="labelcell">Website :</td>
			      <td width="385"> <input name="ts3" type="text" style="width:300px"  value="<?php echo $dulieu['web']?>" />
		              </td>
			    </tr>
			    <tr> 
			      <td class="labelcell">Địa chỉ :</td>
			      <td width="385"> <input name="ts4" type="text" style="width:300px"  value="<?php echo $dulieu['diachi']?>" />
		            </td>
			    </tr>
		
			    <tr> 
			      <td class="labelcell">&nbsp;</td>
			      <td width="385">&nbsp; </td>
			    </tr>
		    </tbody></table>
		    </fieldset>
 		</td>
 		
    	<td valign="top" width="300"><br>
		  			  <fieldset>
			  <legend>Thông tin liên hệ</legend>
			  <table width="300" class="adminform">
			    <tbody>
			    <tr> 
			      <td width="110" class="labelcell"> Điện thoại:</td>
			      <td width="178"> <input name="ts5" type="text" style="width:160px" value="<?php echo $dulieu['sdt']?>" />
		          </td>
			    </tr>
			      <td class="labelcell"> Fax:</td>
			      <td width="178"> <input name="ts6" type="text" style="width:160px" value="<?php echo $dulieu['fax']?> "/>
		          </td>
			    </tr>
			    <tr> 
			      <td class="labelcell"> Email:</td>
			      <td width="178"> <input name="ts7" type="text" style="width:160px" value="<?php echo $dulieu['mail']?>  "/>
		              </td>
			    </tr>
                
			    <tr> 
			      <td colspan="2" align="center">&nbsp;</td>
			    </tr>
			  </tbody></table>
			  </fieldset>
 		</td>
 	</tr>
	
		<tr align="justify"> 
 		<td colspan="2" valign="top" width="800" align="justify"><br>
		  <fieldset>
		  <legend>Giới thiệu trung tâm</legend>
	 		<table width="800" class="adminform">
			    <tbody>
			    <tr align="justify"> 
			      <td width="36" class="labelcell">&nbsp;</td>
			      <td width="752" align="justify">
                  <?php
		$oFCKeditor = new FCKeditor('FCKeditor2') ;
		$oFCKeditor->BasePath = '/fckeditor/' ;
		$oFCKeditor->Value = $dulieu['goithieu'];
		$oFCKeditor->Create() ;
	?>
               </td>
			    </tr>
		    </tbody></table>
		    </fieldset>
 		</td>
 	</tr>
	
</tbody></table>
</form>
		
<?php
}
?>


</div>
